package com.zfl.thread.day05;

public class VolatileDemo01 {

    static volatile boolean flag = true;

    public static void main(String[] args) {
        new Thread(() -> {
            while (true) {
                if (!flag) break;
            }
        }).start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        flag = false;
        System.out.println(Thread.currentThread().getName());

    }
}
